package mn.idax.exchange.otc.service.impl;

import mn.idax.exchange.otc.entity.Country;
import mn.idax.exchange.otc.entity.CountryExample;
import mn.idax.exchange.otc.mapper.CountryMapper;
import mn.idax.exchange.otc.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: jack_huang
 * @Date: 2019/7/1 15:33
 */
@Service
public class CountryServiceImpl implements CountryService {

    @Autowired
    private CountryMapper countryMapper;

    @Override
    public Country getCountryById(Integer id) {
        CountryExample countryExample = new CountryExample();
        countryExample.createCriteria()
                .andIdEqualTo(id);
        List<Country> countries = countryMapper.selectByExample(countryExample);

        return countries.isEmpty() ? null : countries.get(0);
    }
}
